package com.tckdq.tcc.web.controller;

import com.tckdq.tcc.doc.CourseDoc;
import com.tckdq.tcc.dto.SearchCourseParams;
import com.tckdq.tcc.result.JsonResult;
import com.tckdq.tcc.result.PageList;
import com.tckdq.tcc.service.IEsCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/es/course")
public class EsCourseController {
    @Autowired
    private IEsCourseService EsCourseService;

    /*保存课程*/
    @PostMapping("/save")
    public JsonResult saveCourse(@RequestBody CourseDoc doc){
        EsCourseService.save(doc);
        return JsonResult.success();
    }

    /*删除es中的课程*/
    @PostMapping("/delete")
    public JsonResult deleteCourse(@RequestBody Long id){
        EsCourseService.delete(id);
        return JsonResult.success();
    }
    //list页面查询课程
    @PostMapping("/search")
    public JsonResult searchCourse(@RequestBody SearchCourseParams dto){
        PageList pageList=EsCourseService.searchCourse(dto);
        return JsonResult.success(pageList);
    }
}
